// *************************************************************************************************
//
// MK3D Engine
// --------------------------------------
// Copyright (C) 2007-2011 Zeb (mailto: zebbey@gmail.com)
//
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
//
// *************************************************************************************************

#ifndef __H_MK_RENDER_INPUT__
#define __H_MK_RENDER_INPUT__

#include "mk_hardware_buffer.h"

namespace MK3DE
{
	const DWORD RENDER_STREAM_MAX = 8;

	struct RenderInputElemDesc
	{
		STREAM_USAGE usage;
		DWORD usageIndex;       // always 0, except you have more than 1 element with the same usage
		DWORD offset;
		DWORD streamIndex;

		RenderInputElemDesc() {}
		RenderInputElemDesc(STREAM_USAGE _usage, DWORD _usageIndex, DWORD _offset, 
			DWORD _streamIndex) : usage(_usage), usageIndex(_usageIndex),
			offset(_offset), streamIndex(_streamIndex) {}
	};

	class MK3DE_API CRenderInput
	{
	public:
		CRenderInput();
		~CRenderInput();

		DWORD GetVertexBufferSize() { return (DWORD)_vertexStream.size(); }

		CHardwareBuffer* GetVertexBuffer(DWORD idx);
		CHardwareBuffer* GetIndexBuffer();

		BOOL SetVertexBuffer(DWORD idx, CHardwareBuffer* vb);
		void SetIndexBuffer(CHardwareBuffer* ib);

		BOOL GetElementDesc(DWORD idx, RenderInputElemDesc& desc);

	protected:
		BOOL _Create(RenderInputElemDesc* desc, DWORD size);

	protected:
		RenderInputElemDesc* _renderInputElemDesc;
		DWORD _elemNum;

		std::vector<CHardwareBuffer*>     _vertexStream;
		CHardwareBuffer*                  _indexBuffer;
	};
};

#endif // __H_MK_RENDER_INPUT__
